#!/bin/bash

if [ ! -z $1 ];then
	name=$1
fi

if [ ! -z $2 ];then
	value=$2
fi

if [ ! -z $3 ];then
	file=$3
else
	file="/var/www/html/ITemp.php"
fi

if [ ! -z $value ];then
	sed -i "s/^.*'$name' => .*$/'$name' => '$value',/g" $file
fi

if [ $name = "allclear" ]
then 
	cat > /var/www/html/ITemp.php << EOF
<?PHP 
\$SENSOR=array(
'isDie' => '0' ,
'auto_air' => '1' ,
'OP' => '0' ,
'AIR_STATUS' => '0' ,
'AIR_TEMP' => '10' ,
'TEMP' => '29' ,
'env_temp' => '255',
'env_rh' => '255',
'END' => ''
);
?>
EOF
fi

#end
